
<script>
$(window).load(function() {
var user_id = JSON.parse(sessionStorage["user_id"]);

	if(getParameterByName('ID')!=0){
		reorderOnline(getParameterByName('ID'));
	}
});
</script>

    <div class="container-fluid">
      <div class="row-fluid container_bg">
      <div ng-include="'side-menu.html'"></div>
        <div class="span9">
			<div class="container_title">
				<div class=""><h1>Order On-line Medicine</h1></div>
				<div class="container_form_top" ng-repeat="p in postss">
				<form id="orderForm" name="orderForm" class="form-horizontal" ng-submit="sendOrder(orderForm)" enctype="multipart/form-data">
					<div class="control-group">
						<label class="control-label" for="inputUser">User Name</label>
						<div class="controls">
						<input type="text" class="span8" id="inputuser" name="inputuser" value="{{ p.user_name }}" readonly>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputEmail">Email</label>
						<div class="controls">
						<input type="text" class="span8" id="inputEmail" name="inputEmail" value="{{ p.email }}" readonly >
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="landMark">Land Mark</label>
						<div class="controls">
						<input type="text" class="span8" id="inputLm" name="inputLm" placeholder="Land Mark" value="{{ p.landmark }}" ng-model="p.landmark" required>
						<span class="error" ng-show="orderForm.inputLm.$error.required"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="txtArea">Address</label>
						<div class="controls">
						<textarea rows="3" class="span8" id="txtArea" name="txtArea" ng-model="p.address" required >{{ p.address }}</textarea>
						<span class="error" ng-show="orderForm.txtArea.$error.required"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputPh">Phone Number</label>
						<div class="controls">
						<input type="tel" pattern="[0-9]{10}" class="span8" id="inputPh" name="inputPh" placeholder="Phone Number" value="{{ p.phone }}" ng-model="p.phone" required />
						<span class="error" ng-show="orderForm.inputPh.$error.required"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputPh">Alterphonenumber</label>
						<div class="controls">
						<input type="tel" pattern="[0-9]{10}" class="span8" id="alterphone" name="alterphone" placeholder="Please Enter Telephone Number" value="{{ p.alterphone }}" ng-model="p.alterphone" required />
						<span class="error" ng-show="orderForm.alterphone.$error.required"></span>
						</div>
					</div>
					<div id="Display_images"></div>
					<div class="control-group" ng-controller="AppController" nv-file-drop="" uploader="uploader" filters="queueLimit, customFilter">
						<label class="control-label" for="inputUp">Upload Prescriptions</label>
						<div class="controls">
							<input type="file" nv-file-select="" uploader="uploader" />
						</div>
						 <table class="table">
                        <thead>
                            <tr>
                                <th width="50%">Name</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-repeat="currOldOrderImage in oldOrderImagesQueue">
                                <td><strong>{{ currOldOrderImage.name }}</strong></td>
                                <td class="text-center">
                                </td>
                                <td nowrap>
                                    <button type="button" class="btn btn-danger btn-xs" ng-click="currOldOrderImage.removeCurrImage()">
                                        <span class="glyphicon glyphicon-trash"></span> Remove
                                    </button>
                                </td>
                            </tr>
                            <tr ng-repeat="item in uploader.queue">
                                <td><strong>{{ item.file.name }}</strong></td>
                                <td class="text-center">
                                    <span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span>
                                    <span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span>
                                    <span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span>
                                </td>
                                <td nowrap>
                                    <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
                                        <span class="glyphicon glyphicon-trash"></span> Remove
                                    </button>
                                </td>
                            </tr>
                        </tbody>
                    </table>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputPh">Manual Insert</label>
						<div class="controls" id="reorder_tablets_div">
							<input type="text" class="span4" id="tabletName" name="tabletName" placeholder="Ex: Alex Cough Formula (100 ml)" ng-model="p.tabletName" value="{{ p.tabletName }}" required>
							<input type="number" class="span2" id="quantity" name="quantity" placeholder="Ex:4" ng-model="p.quantity" value="{{ p.quantity }}" required >
							<a href="javascript:void(0);" ng-click="addPrescription()" class="addmore">Add Another</a>
							<span id="add1">
								<div ng-repeat="currDosageDetail in p.dosageDetails" id="removedivp{{ p.dosageDetails.indexOf(currDosageDetail)+1 }}" class="fileremove">
									<input type="text" class="span4" name="tabletNamee[{{ p.dosageDetails.indexOf(currDosageDetail)+1 }}]" ng-model="currDosageDetail.tabletName" ng-value="{{ currDosageDetail.tabletName }}" placeholder="Ex: Alex Cough Formula (100 ml)" id="tabletName" required>
									<input type="number" class="span2" name="quantityy[{{ p.dosageDetails.indexOf(currDosageDetail)+1 }}]" ng-model="currDosageDetail.tabletQuantity" ng-value="{{ currDosageDetail.tabletQuantity }}" placeholder="Ex:4" id="quantity" required>
									<a href="javascript:void(0)" id="remove" class="delete" ng-click="currDosageDetail.removeCurrDosage();"> Delete </a>
								</div>
							</span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputAd">Auto renewal</label>
						<div class="controls">
							<input type="radio" id="autoRenewal1" name="auto_renewal" value="1" ng-model="p.auto_renewal" ng-required="!autoRenewal" ng-click="onlineFn(0)"> Yes &nbsp;&nbsp;
							<input type="radio" id="autoRenewal0" name="auto_renewal" value="0" ng-model="p.auto_renewal" ng-required="!autoRenewal" ng-click="offlineFn(0)"> No
						</div>
					</div>
					<div class="control-group" style="display:none" id="eachDaysRadio">
						<label class="control-label" for="inputPh">Number of days</label>
						<div class="controls">
						<input type="number" class="span4" id="eachDays" name="eachDays" ng-model="p.eachDays">
						<span class="error" ng-show="orderForm.eachDays.$error.required"></span>
						</div>
					</div>
					<div class="control-group">
						<label class="control-label" for="inputAd">Select Timings</label>
						<div class="controls">
							<input type="radio" id="Timings0" name="immediate" value="0" ng-model="p.immediate" ng-required="!Timings" ng-click="offlineFn(1)"> Available &nbsp;&nbsp;
							<input type="radio" id="Timings1" name="immediate" value="1" ng-model="p.immediate" ng-required="!Timings" ng-click="onlineFn(1)"> Immediate
						</div>
					</div>
					<div class="control-group" style="display:none" id="availableRadio">
						<label class="control-label" for="inputPh">Available Timimgs</label>
						<div class="controls">
							<input type="text" class="span4" id="available_time" name="availabletime" value="{{ p.availabletime }}" ng-model="p.availabletime" ng-required="p.immediate == 0" >
							<p>Ex:(11:00am-12:00pm)or(01:00am-02:00am)</p>
							<span class="error" ng-show="orderForm.availabletime.$error.required"></span>
							<span style="color:red">{{ errorTime }}</span>
						</div>
					</div>
					<div class="control-group">
						<div class="controls">
						<button type="submit" class="medicart_btn">SAVE</button><span ng-bind-html="onlineloading"></span>
						</div>
					</div>
					<input type="hidden" id="user_id" name="user_id" ng-model="p.user_id" value="{{ userId }}">
					<input type="hidden" id="oldorderId" name="oldorderId" ng-model="p.oldorderId" ng-init="p.oldorderId='0'" value="0" />
					<input type="hidden" id="countFiles" name="countFiles" value="{{ countFiles }}">
					<input type="hidden" id="countFile" name="countFile" value="{{ countFile }}">
					<input type="hidden" id="countFileReorder" name="countFileReorder" value="2">
					<input type="hidden" id="hid_value" name="hid_value" value="ORDER">
					<input type="text" id="hidImages" name="p.prescription_upload_path" ng-model="p.prescription_upload_path" value="{{ p.prescription_upload_path }}" ng-show="false">
				</form>
				</div>
			</div>
		<p style="color:red" id="textboxes"></p>
		<p style="color:red" id="textboxess"></p>
         <div><p class="note_c">Note -</p>
		 <p><i class=" icon-arrow-right"></i>&nbsp;You are required to send a scan copy of valid prescription from authorised Doctor which is mandatory.</p>
		<p><i class=" icon-arrow-right"></i>&nbsp;No medicine will be delivered without prescription.</p>
		<p><i class=" icon-arrow-right"></i>&nbsp;A minimum order of Rs 200 is required </p>		 
		 </div>
        </div>
      </div>
    </div>
	

<script>

  function add(){
	 var num=$('#countFileReorder').val();
    $("#add1").append('<div id="removediv'+num+'" class="fileremove"><input type="text" class="span4" name="tabletName[]" id="tabletName" placeholder="Ex: Alex Cough Formula (100 ml)"><input type="number" class="span2" name="quantity[]" id="quantity" placeholder="Ex:4"><a href="javascript:void(0)" id="remove" class="delete" onclick="removediv1('+num+');"> Delete </a></div>');
	num=parseInt(num)+1;
	$('#countFileReorder').val(num);
  }

</script>